package com.unidt.www.module.expert.controller.admin;

import com.alibaba.fastjson.JSON;
import com.unidt.www.framework.common.core.KeyValue;
import com.unidt.www.framework.common.pojo.CommonResult;
import com.unidt.www.framework.sms.core.client.SmsClient;
import com.unidt.www.framework.sms.core.client.SmsClientFactory;
import com.unidt.www.framework.sms.core.client.SmsCommonResult;
import com.unidt.www.framework.sms.core.client.dto.SmsSendRespDTO;
import com.unidt.www.framework.sms.core.enums.SmsChannelEnum;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author sk
 * @Description:
 * @Date 2022/12/21 16:34
 **/
@Api(tags = "专家邀约-短息测试")
@RestController
@RequestMapping("/expert/sms")
public class SmsTestController {

    @Autowired
    SmsClientFactory smsClientFactory ;

    @GetMapping("/test/")
    @ApiOperation(value = "短息测试")

    public CommonResult test(){
        SmsClient tencentSmsClient = this.smsClientFactory.getSmsClient(SmsChannelEnum.TENCENT.getCode());
        List<KeyValue<String,Object>> params = new ArrayList<>();
        params.add(new KeyValue(1,"http://www.exe.com/xxx") );
        params.add(new KeyValue(2,"5") );

        SmsCommonResult<SmsSendRespDTO> respDTOSmsCommonResult =  tencentSmsClient.sendSms(System.currentTimeMillis(),"13162891746","86435",params);
        System.out.println(JSON.toJSONString(respDTOSmsCommonResult));
        return  CommonResult.success("成功") ;
    }
}
